package Game;

public class KeyStroke {
    private int keycode;
    private long timestamp;

    public KeyStroke(int keycode, long timestamp) {
        this.keycode = keycode;
        this.timestamp = timestamp;
    }

    public KeyStroke(int keycode) {
        this.keycode = keycode;
        this.timestamp = Timestamp.getNow();
    }

    public KeyStroke(String ID_line) {
        String[] split = ID_line.split(Packet.SEPARATOR[2]);
        keycode = Integer.parseInt(split[0].substring(1));
        timestamp = Long.parseLong(split[1].substring(0, split[1].length()-1));
    }
 
    public int getKeycode() {
        return keycode;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    @Override
    public String toString() {
        return "<"+keycode+Packet.SEPARATOR[2]+timestamp+">";
    }

}
